package com.lindroy.jetpacknotes.logic.network

import com.lindroy.jetpacknotes.logic.model.ApiResponse
import com.lindroy.jetpacknotes.logic.model.ArticleResp
import com.lindroy.jetpacknotes.logic.model.PageModel
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.http.GET
import retrofit2.http.Path
import retrofit2.http.Query

/**
 * @author Lin
 * @date 2022/1/14
 * @function
 */
interface ApiService {

    @GET("article/list/{page}/json")
    suspend fun getArticles(@Path("page") page: Int,
                            @Query("page_size") pageSize: Int): ApiResponse<PageModel<ArticleResp>>

    companion object {
        fun create() = Retrofit.Builder()
            .baseUrl("https://www.wanandroid.com/")
            .addConverterFactory(GsonConverterFactory.create())
            .build()
            .create(ApiService::class.java)
    }
}